<nz-divider></nz-divider>
<nz-breadcrumb>
  <nz-breadcrumb-item>
    <a [routerLink]="['/']">
      <i nz-icon nzType="home"></i>
      <span>{{ 'menu.dashboard' | i18n }}</span>
    </a>
  </nz-breadcrumb-item>
  <nz-breadcrumb-item>
    <a [routerLink]="['/monitors']" [queryParams]="{ app: app ? app : '' }">
      <i nz-icon nzType="reconciliation"></i>
      <span>{{ 'monitors.list' | i18n }}</span>
    </a>
  </nz-breadcrumb-item>
  <nz-breadcrumb-item>
    <span nz-icon nzType="pie-chart"></span>
    <span>{{ 'monitors.detail' | i18n }}</span>
    <nz-tag style="font-size: 14px; border-radius: 4px; margin-left: 4px" nzColor="#3f51b5">
      <span>{{ 'monitor.app.' + app | i18n }}</span>
    </nz-tag>
    <a [href]="'https://hertzbeat.com/docs/help/' + app" target="_blank" style="float: right; margin-right: 5%">
      <button nz-button nzType="primary">
        <span>{{ 'common.button.help' | i18n }} </span>
        <span nz-icon nzType="question-circle"></span>
      </button>
    </a>
  </nz-breadcrumb-item>
</nz-breadcrumb>
<nz-divider></nz-divider>

<nz-layout>
  <nz-sider nzWidth="19%" nzTheme="light">
    <nz-card nzHoverable style="width: 100%; height: 100%" [nzBordered]="true" [nzTitle]="monitor_basic_card_title">
      <div nz-row nzGutter="16">
        <div nz-col nzSpan="8"><p style="text-align: right">ID</p></div>
        <div nz-col nzSpan="16"
          ><p style="text-align: left">{{ monitorId }}</p></div
        >
      </div>
      <div nz-row nzGutter="16">
        <div nz-col nzSpan="8"
          ><p style="text-align: right">{{ 'monitors.detail.name' | i18n }}</p></div
        >
        <div nz-col nzSpan="16"
          ><p style="text-align: left">{{ monitor?.name }}</p></div
        >
      </div>
      <div nz-row nzGutter="16">
        <div nz-col nzSpan="8"><p style="text-align: right">HOST</p></div>
        <div nz-col nzSpan="16"
          ><p style="text-align: left">{{ monitor?.host }}</p></div
        >
      </div>
      <div nz-row nzGutter="16">
        <div nz-col nzSpan="8"
          ><p style="text-align: right">{{ 'monitors.detail.port' | i18n }}</p></div
        >
        <div nz-col nzSpan="16"
          ><p style="text-align: left">{{ port }}</p></div
        >
      </div>
      <div nz-row nzGutter="16">
        <div nz-col nzSpan="8"
          ><p style="text-align: right">{{ 'monitors.detail.description' | i18n }}</p></div
        >
        <div nz-col nzSpan="16"
          ><p style="text-align: left">{{ monitor?.description }}</p></div
        >
      </div>
      <div nz-row nzGutter="16">
        <div nz-col nzSpan="8"
          ><p style="text-align: right">{{ 'monitors.detail.status' | i18n }}</p></div
        >
        <div nz-col nzSpan="16">
          <nz-tag *ngIf="monitor?.status == 0" nzColor="default">
            <i nz-icon nzType="robot" nzTheme="outline"></i>
            <span>{{ 'monitor.status.un-manage' | i18n }}</span>
          </nz-tag>
          <nz-tag *ngIf="monitor?.status == 1" nzColor="success">
            <i nz-icon nzType="smile" nzTheme="outline"></i>
            <span>{{ 'monitor.status.available' | i18n }}</span>
          </nz-tag>
          <nz-tag *ngIf="monitor?.status == 2" nzColor="warning">
            <i nz-icon nzType="meh" nzTheme="outline"></i>
            <span>{{ 'monitor.status.unavailable' | i18n }}</span>
          </nz-tag>
          <nz-tag *ngIf="monitor?.status == 3" nzColor="error">
            <i nz-icon nzType="frown" nzTheme="outline"></i>
            <span>{{ 'monitor.status.unreachable' | i18n }}</span>
          </nz-tag>
        </div>
      </div>
      <div nz-row nzGutter="16">
        <div nz-col nzSpan="8"
          ><p style="text-align: right">{{ 'monitor.intervals' | i18n }}</p></div
        >
        <div nz-col nzSpan="16"
          ><p style="text-align: left">{{ monitor?.intervals }}s</p></div
        >
      </div>
      <div nz-row nzGutter="16">
        <div nz-col nzSpan="8"
          ><p style="text-align: right">{{ 'common.new-time' | i18n }}</p></div
        >
        <div nz-col nzSpan="16"
          ><p style="text-align: left">{{ monitor?.gmtCreate | date: 'YYYY-MM-dd HH:mm:ss' }}</p></div
        >
      </div>
      <div nz-row nzGutter="16">
        <div nz-col nzSpan="8"
          ><p style="text-align: right">{{ 'common.edit-time' | i18n }}</p></div
        >
        <div nz-col nzSpan="16"
          ><p style="text-align: left">{{ monitor?.gmtUpdate | date: 'YYYY-MM-dd HH:mm:ss' }}</p></div
        >
      </div>
    </nz-card>
  </nz-sider>
  <nz-layout>
    <nz-content>
      <nz-tabset nzType="card">
        <nz-tab [nzTitle]="titleTemplate">
          <ng-template #titleTemplate>
            <i nz-icon nzType="pic-right" style="margin-left: 10px"></i>
            {{ 'monitors.detail.realtime' | i18n }}
          </ng-template>
          <div style="display: flex; justify-content: flex-start; flex-wrap: wrap">
            <div *ngFor="let metric of metrics; let i = index">
              <app-monitor-data-table [metrics]="metric" [monitorId]="monitorId"></app-monitor-data-table>
            </div>
          </div>
        </nz-tab>
        <nz-tab [nzTitle]="title2Template" (nzClick)="initMetricChart()">
          <ng-template #title2Template>
            <i nz-icon nzType="pic-right" style="margin-left: 10px"></i>
            {{ 'monitors.detail.history' | i18n }}
          </ng-template>
          <div style="display: flex; justify-content: flex-start; flex-wrap: wrap">
            <div *ngFor="let item of chartMetrics; let i = index">
              <app-monitor-data-chart
                [app]="app"
                [metrics]="item.metrics"
                [metric]="item.metric"
                [unit]="item.unit"
                [monitorId]="monitorId"
              ></app-monitor-data-chart>
            </div>
          </div>
        </nz-tab>
      </nz-tabset>
    </nz-content>
  </nz-layout>
</nz-layout>

<ng-template #monitor_basic_card_title>
  <p style="font-size: small; text-align: left; margin-bottom: 3px">{{ 'monitors.detail.basic' | i18n }}</p>
</ng-template>
